const {http,handleStr,getAlbumUrl} = require("../../utils/util");
Page({
  data:{
    albums:[]
  },
  onLoad: function () {
    // var url = "http://47.108.197.28:3000/top/album";
    // http({
    //   url,
    //   success:res=>this.handleHttpData(res)
    // })
    getAlbumUrl().then(res=>this.handleHttpData(res))
  },
  handleHttpData(res){
    var albums = [];
    res.data.albums.forEach(item=>{
      var{name,blurPicUrl,id} = item;
      albums.push({
        name:handleStr(name),
        blurPicUrl,
        id
      })
    })
    this.setData({
      albums
    })
  },
  onTap(event){
    var id = event.currentTarget.dataset.aid;
    wx.navigateTo({
      url: `/pages/detail/detail?id=${id}`,
    })
  }
})
